import Cookies from 'js-cookie'

const TokenKey = 'token'
const UserInfo = 'userinfo'
const MqttInfo = 'mqttinfo'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getUserInfo() {
  return Cookies.get(UserInfo)
}

export function setUserInfo(user) {
  return Cookies.set(UserInfo, user)
}

export function removeUserInfo() {
  return Cookies.remove(UserInfo)
}

export function setMqttInfo(mqtt) {
  return Cookies.set(MqttInfo, JSON.stringify(mqtt))
}
export function getMqttInfo() {
  if (Cookies.get(MqttInfo)){
    return JSON.parse(Cookies.get(MqttInfo))
  }
  return false
}
export function removeMqttInfo() {
  return Cookies.remove(MqttInfo)
}


